﻿using System;
using System.Linq;
using GdHotel.Data.Interfaces;

namespace GdHotel.Data.Repositories
{
    public class EmailsRepository : IEmailsRepository
    {
        private GdHotelEntities entities = new GdHotelEntities();

        public IQueryable<Email> FindAll()
        {
            return entities.Emails.AsQueryable();
        }

        public IQueryable<Email> FindAllByLang(Language lang)
        {
            return entities.Emails.AsQueryable();
        }

        public Email GetById(Int32 id)
        {
            return entities.Emails.SingleOrDefault(email => email.Id == id);
        }

        public void Insert(Email email)
        {
            entities.AddToEmails(email);
        }

        public void Delete(Email email)
        {
            entities.Emails.DeleteObject(email);
        }

        public void Save()
        {
            entities.SaveChanges();
        }

        public void Dispose()
        {
            entities.Dispose();
        }
    }
}
